package com.xt.back.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xt.back.entity.Relation;
import com.xt.back.mapper.RelationMapper;
import com.xt.back.service.IRelationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 * 关系信息表 服务实现类
 * </p>
 *
 * @author leotong
 * @since 2022-04-03
 */
@Service
@AllArgsConstructor
public class RelationServiceImpl extends ServiceImpl<RelationMapper, Relation> implements IRelationService {

    private final RelationMapper relationMapper;

    @Override
    public Page<Relation> getRelationByPage(Relation relation) {
        Page<Relation> page=new Page<>(relation.pageNum,relation.pageSize);
        QueryWrapper<Relation> queryWrapper=new QueryWrapper<>();
        queryWrapper.lambda().like(!Objects.equals(relation.getRelationName(),""),Relation::getRelationName,relation.getRelationName())
                .eq(!Objects.equals(relation.getRelationType(),""),Relation::getRelationType,relation.getRelationType());
        return relationMapper.selectPage(page,queryWrapper);
    }
}
